package com.itbaizha.servlet;

import com.itbaizhan.domain.Student;
import com.itbaizhan.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/allStudent.do")
public class FindAllStudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StudentService studentService = new StudentService();
        try{
            List<Student> allStudent = studentService.findAllStudent();
            //放进全局容器
            req.setAttribute("allStudent",allStudent);
        }catch (Exception e){
            e.printStackTrace();
        }
        //请求转发
        req.getRequestDispatcher("allStudent.jsp").forward(req,resp);
    }
}
